export function formatDateTime(date, fmt) {
var fmt="yyyy-MM-dd hh:mm:ss";
    var d = new Date(times) ;
    
    if (pattern) {
        fmt = pattern ;
    }
    var o = {
        "M+": d.getMonth() + 1,                 //月份
        "d+": d.getDate(),                    //日
        "h+": d.getHours(),                   //小时
        "m+": d.getMinutes(),                 //分
        "s+": d.getSeconds(),                 //秒
        "q+": Math.floor((d.getMonth() + 3) / 3), //季度
        "S": d.getMilliseconds()             //毫秒
    };
    if (/(y+)/.test(fmt))
        fmt = fmt.replace(RegExp.$1, (d.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt))
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
};

export function diffFormatDateTime(date) {
  var diff = new Date().getTime().date ;
  var fmt = "" ;
  if (diff < 60*1000)
    fmt = Math.floor(diff/1000) +"秒";
  else if (diff <60 * 60 *1000)
    fmt = Math.floor(diff/(1000 * 60)) +"分钟";
  else if (diff < 24*60*60*1000)
    fmt = Math.floor(diff/(1000 * 60 * 60)) +"小时";
  else
    fmt = Math.floor(diff/(1000 * 60 * 60 * 24)) +"天";
  
  fmt = fmt + "前";
  return fmt;
};